package fr.imag.adele.mediation.probes.impl;

import fr.imag.adele.mediation.probes.services.Probe;
import fr.imag.adele.mediation.probes.services.Scheduler;
import fr.imag.adele.mediation.probes.util.DataEvent;

public class StandardScheduler implements Scheduler, Runnable {
	private long  	m_interval;
	private Probe 	m_parentProbe;	
	private boolean m_working;
	
	public void notify(DataEvent dataEvent) {
		
	}
	public void fire() {
		if (getParentProbe() != null) {
			getParentProbe().process();
		}
	}
	public Probe getParentProbe() {
		return m_parentProbe;
	}	
	public void setParentProbe(Probe probe) {
		m_parentProbe = probe;
	}
	public void start(){
		Thread t = new Thread(this);
		m_working=true;				
		t.start();		
	}
	public void stop(){
		m_working = false;
	}
	public void run() {
		while (m_working==true){
			try {
				// fire
				fire();
				// wait t time			
				Thread.sleep(m_interval);
			} catch (InterruptedException e) {	
			}
		}
	}
}
